<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}" class="dark">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ .Site.Title }} - {{ .Title }}</title>
    <style>
        :root {
            --background: #f8f9fa;
            --card-background: #ffffff;
            --text: #212529;
            --text-secondary: #495057;
            --primary: #1a73e8;
            --border: #dee2e6;
        }

        .dark {
            --background: #1a1d21;
            --card-background: #25292e;
            --text: #f8f9fa;
            --text-secondary: #adb5bd;
            --primary: #4285f4;
            --border: #495057;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 0;
            background-color: var(--background);
            color: var(--text);
            transition: background-color 0.3s ease;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1.5rem;
        }

        .hero {
            background-size: cover;
            background-position: center;
            padding: 6rem 1.5rem;
            margin-bottom: 3rem;
            text-align: center;
            color: white;
        }

        .content-section {
            margin-bottom: 3rem;
        }

        .section-title {
            font-size: 1.5rem;
            font-weight: 600;
            margin-bottom: 1.5rem;
            color: var(--text);
        }

        .content-links {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 1.5rem;
        }

        .content-card {
            background-color: var(--card-background);
            border: 1px solid var(--border);
            border-radius: 0.5rem;
            padding: 1.5rem;
            transition: all 0.3s ease;
            height: 100%;
        }

        .content-card:hover {
            transform: translateY(-0.25rem);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            border-color: var(--primary);
        }

        .content-card h3 {
            font-size: 1.25rem;
            font-weight: 600;
            margin-top: 0;
            margin-bottom: 0.75rem;
            color: var(--text);
        }

        .content-card a {
            text-decoration: none;
            color: inherit;
            display: block;
            height: 100%;
        }

        .content-card p {
            color: var(--text-secondary);
            margin-bottom: 0.75rem;
            font-size: 0.9375rem;
        }

        .content-card small {
            color: var(--text-secondary);
            font-size: 0.8125rem;
        }

        .featured-content {
            background-color: var(--card-background);
            border: 1px solid var(--border);
            border-radius: 0.5rem;
            padding: 2rem;
            margin-bottom: 3rem;
        }

        .featured-text {
            color: var(--text-secondary);
            line-height: 1.7;
        }

        .featured-text h2,
        .featured-text h3 {
            color: var(--text);
        }

        @media (max-width: 768px) {
            .content-links {
                grid-template-columns: 1fr;
            }

            .container {
                padding: 0 1rem;
            }

            .hero {
                padding: 4rem 1rem;
            }
        }
    </style>
</head>

<body>
    <main>
        <!-- Hero 区域 -->
        {{ with .Params.banner }}
        <section class="hero" style="background-image: url('{{ .image }}')">
            <div class="container">
                <h1>{{ $.Title }}</h1>
            </div>
        </section>
        {{ end }}

        <div class="container">
            <!-- 精选内容区域 - 显示 content/_index.md 内容 -->
            <section class="featured-content">
                <h2 class="section-title">精选内容</h2>
                <div class="featured-text">
                    {{ .Content }}
                </div>

                <!-- 精选文章 -->
                <div class="content-links" style="margin-top: 2rem;">
                    {{ range first 3 (where .Site.RegularPages "Params.featured" true) }}
                    <div class="content-card">
                        <a href="{{ .RelPermalink }}">
                            <h3>{{ .Title }}</h3>
                            <p>{{ .Description | default .Summary }}</p>
                            {{ with .Params.date }}<small>发布日期: {{ .Format "2006-01-02" }}</small>{{ end }}
                        </a>
                    </div>
                    {{ end }}
                </div>
            </section>

            <!-- 按分类分组的内容区域 -->
            {{ $sections := where .Site.Sections "Pages" "!=" nil }}
            {{ range $sections }}
            <section class="content-section">
                <h2 class="section-title">{{ .Title | humanize | title }}</h2>
                <div class="content-links">
                    {{ range .Pages }}
                    <div class="content-card">
                        <a href="{{ .RelPermalink }}">
                            <div class="thumbnail-container">
                                {{ $thumbnail := "" }}
                                {{ with .Params.thumbnail }}
                                {{ $thumbnail = resources.Get . }}
                                {{ else }}
                                {{ with .Resources.GetMatch "cover*" }}
                                {{ $thumbnail = . }}
                                {{ end }}
                                {{ end }}

                                {{ if $thumbnail }}
                                {{ $thumbnail := $thumbnail.Fill "600x400 Center" }}
                                <img src="{{ $thumbnail.RelPermalink }}" alt="{{ .Title }}" class="thumbnail"
                                    loading="lazy" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}">
                                {{ else }}
                                <img src="/img/2.png" alt="默认缩略图" class="thumbnail" loading="lazy">
                                {{ end }}
                            </div>
                            <div class="card-content">
                                <h3>{{ .Title }}</h3>
                                <p>{{ .Description | default (truncate 100 .Summary) }}</p>
                                {{ with .Params.date }}<small>{{ .Format "2006-01-02" }}</small>{{ end }}
                            </div>
                        </a>
                    </div>
                    {{ end }}
                </div>
            </section>
            {{ end }}
        </div>
    </main>
</body>

</html>